package dataImport.model;

import dataImport.model.abstracts.AbstractEntity;


public class Description extends AbstractEntity {

	private static final long serialVersionUID = 7401669492639603367L;

	private State state;

	private String text;

	private Object objectRelatedTo;

	private Place placeRelatedTo;

	public Description(final String id, final State state, final String text, final Object objectRelatedTo) {
		super(id);
		this.state = state;
		this.text = text;
		this.objectRelatedTo = objectRelatedTo;
		this.placeRelatedTo = null;
	}

	public Description(final String id, final State state, final String text, final Place placeRelatedTo) {
		super(id);
		this.state = state;
		this.text = text;
		this.objectRelatedTo = null;
		this.placeRelatedTo = placeRelatedTo;
	}

	public Description(final String id, final String text, final Object objectRelatedTo) {
		this(id, null, text, objectRelatedTo);
	}

	public Description(final String id, final String text, final Place placeRelatedTo) {
		this(id, null, text, placeRelatedTo);
	}

	public boolean isRelatedToObject() {
		return this.objectRelatedTo != null;
	}

	public boolean isRelatedToPlace() {
		return this.placeRelatedTo != null;
	}

	public State getState() {
		return this.state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Object getObjectRelatedTo() {
		return this.objectRelatedTo;
	}

	public void setObjectRelatedTo(Object objectRelatedTo) {
		this.objectRelatedTo = objectRelatedTo;
	}

	public Place getPlaceRelatedTo() {
		return this.placeRelatedTo;
	}

	public void setPlaceRelatedTo(Place placeRelatedTo) {
		this.placeRelatedTo = placeRelatedTo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((this.objectRelatedTo == null) ? 0 : this.objectRelatedTo.hashCode());
		result = prime * result + ((this.placeRelatedTo == null) ? 0 : this.placeRelatedTo.hashCode());
		result = prime * result + ((this.state == null) ? 0 : this.state.hashCode());
		result = prime * result + ((this.text == null) ? 0 : this.text.hashCode());
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (this.getClass() != obj.getClass()) {
			return false;
		}
		Description other = (Description) obj;
		if (this.objectRelatedTo == null) {
			if (other.objectRelatedTo != null) {
				return false;
			}
		}
		else if (!this.objectRelatedTo.equals(other.objectRelatedTo)) {
			return false;
		}
		if (this.placeRelatedTo == null) {
			if (other.placeRelatedTo != null) {
				return false;
			}
		}
		else if (!this.placeRelatedTo.equals(other.placeRelatedTo)) {
			return false;
		}
		if (this.state == null) {
			if (other.state != null) {
				return false;
			}
		}
		else if (!this.state.equals(other.state)) {
			return false;
		}
		if (this.text == null) {
			if (other.text != null) {
				return false;
			}
		}
		else if (!this.text.equals(other.text)) {
			return false;
		}
		return true;
	}
}
